<!DOCTYPE HTML>
<html lang="zh-CN"><head>
	<title>{$name}</title>
	<meta charset="UTF-8">
	<meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<link href="{$Think.config.RESOURCEURL}wx_assets/micontent/materiaDetail.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
	<link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
	<link href="{$Think.config.RESOURCEURL}wx_assets/dist/gmu.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
	<link href="{$Think.config.RESOURCEURL}wx_assets/css/product/product_detail.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
	<if condition="$mallHue.mallHue eq '1'">
		<link href="{$Think.config.RESOURCEURL}wx_assets/css/product/crowdfunding_detail_blue.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
		<else/>
		<link href="{$Think.config.RESOURCEURL}wx_assets/css/product/crowdfunding_detail.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
	</if>
	<link href="{$Think.config.RESOURCEURL}wx_assets/css/iconfont/font_tuan.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
	<!-- <script src="http://sdk.talkingdata.com/app/h5/v1?appid=DE13C350F41F5DE78FEC51DB5DE730D1&vn=v2&vc=v2"></script> -->
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/dist/gmu.min.js{$Think.config.RESOURCE_VER}"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}"></script>
	<script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
</head>
<body>
<!--关注浮层 begin-->
<!--0表示未关注，1表示已关注-->
<if condition="$subscribe eq '0'">
	<div class="careview">
		<img src="{$mall.logo}" alt="" />
		<a href='{$mall.wechaturl}'>立即关注</a>
		<empty name="mall.recommend">
			<p>{$mall.wechatname}</p>
			<else />
			<p>{$mall.recommend}</p>
		</empty>

		<span></span>
	</div>
	<script>
		function closePlayMsgView(){
			$('.play_msg').hide();
		}
		$(function(){
			var isfirst=getCookie('new_detail');
			if(isfirst!=1)
			{
				$('.play_msg').show();
				setCookie("new_detail","1");
			}

		})

		$('.careview > span').on('click',function(){
			$('.careview').hide();
		});
	</script>
</if>

<div class="detail-slider-container" style="margin-top: 0px;position:relative">
	<ul class="pro-list" id="detail-slider" >
		<volist name="picUrl1" id="picItem">
			<if condition="$i neq '1'">
				<li l="true">
					<img class="default" src="{$picItem:picUrl}">
				</li>
			</if>
		</volist>
	</ul>
	<if condition = "$inventory eq '1' AND $inventoryCount elt '0'">
		<div class="soldOut"></div>
	</if>
</div>
<script type="text/javascript">
	var loop = $("#detail-slider li").size() > 2;
	$("#detail-slider").slider({
		loop: loop,
		imgZoom: false,
		arrow: false,
		autoPlay: false,
		slide: function(e, to, from) {
		}
	});
	if ($("#detail-slider li").size() > 1) {
		$(".ui-slider-dots").css("marginLeft", $(".ui-slider-dots").width() / 2 * -1);
	} else {
		$(".ui-slider-dots").hide();
	}
</script>
<div class="container">
	<h1 class="name">{$name}</h1>
	<div class="progress">
		<div>
			<div>
				<div class="blueCircle">{$supportPerson}</div>
			</div>
			<span>支持人数</span>
		</div>
		<div>
			<div>{$progress}%<br/>
				<if condition="$crowdStatus gt 1">
					已结束
					<else/>
					众筹中
				</if>

			</div>
		</div>
		<div>
			<div>
				<div class="blueCircle">{$day}天</div>
			</div>
			<if condition="$isStart eq '1'">
				<span>剩余时间</span>
				<elseif condition="$isEnd eq '1' or $crowdStatus eq '2'"/>
				<span>已结束</span>
				<else/>
				<span>距离开始</span>
			</if>

		</div>
	</div>
	<div class="target">
		<div>
			<h1>￥{$crowTarget}</h1>
			<span>目标金额</span>
		</div>
		<div>
			<h1>￥{$supportSum}</h1>
			<span>已筹金额</span>
		</div>
	</div>
	<if condition="$recommend neq ''">
		<div class="recommend">
			{$recommend}
		</div>
	</if>
	<notempty name="priceTag">
		<div class="pro-esp">
			<volist name="priceTag" id="pct">
				<span><i class="iconfont">&#xe604;</i>{$pct}</span>
			</volist>
		</div>
	</notempty>
	<if condition="$description neq ''">
		<div class="description">
			{$description}
		</div>
	</if>
</div>
<div class="p-detail">
	{$webPageContent}
</div>
<div class="menu">
	<if condition="$favorite eq '1'">
		<a id="favorite" class="current" favorite="1"><i class="iconfont">&#xe607;</i><span>已收藏</span></a>
		<else/>
		<a id="favorite"><i class="iconfont">&#xe606;</i><span>收藏</span></a>
	</if>
	<if condition="$isEnd eq '1' or $isStart neq '1' or $crowdStatus gt 1">
		<a class="disabled">我要支持</a>
		<else/>
		<a id="support">我要支持</a>
	</if>

</div>
<a id="car" class="car" onclick="detail.goCart('{$vId}')">
	<i class="iconfont">&#xe608;</i>
		<span>
			<p id="carNum"></p>
		</span>
</a>
<input type="hidden" id="shareImg" value="<php>echo $picUrl1[1]->picUrl;</php>">
<script type="text/javascript">
	var baseUrl = '{$Think.config.SERVER_HOST}';
	var hrefPath = baseUrl+'call.html?customerId={$customerId}';
	var basePath = baseUrl+'call.json?customerId={$customerId}&userName={$userName}';
	var p=$.util.getParamAsObject();
	var detail={
		cartList:null,//购物车详情
		guid:"{$guid}",
		init:function(){
			this._initEvent();
			this.getCartGoodsNum();
		},
		_initEvent:function(){
			var me = this;
			$("#support").click(function(){
                var p=$.util.getParamAsObject();
                p.id="{$id}";
                p.visitId="{$visitId}";
				p=encodeURIComponent(JSON.stringify(p));
				location.href  = baseUrl+'call.html?customerId={$customerId}&module=product&method=crowdStall&params='+p;
			});
			$("#favorite").click(function() {
				var me = $(this);
				var favorite = $(this).attr("favorite");
				var customerId = $.util.getParam("customerId");
				if (favorite == "1") {
					var method = "removeFavorite";
				} else {
					var method = "addFavorite";
				}
				$.util.pageLoading.show();
				$.req.get("call.json?customerId=" + customerId + "&module=product&method=" + method, {
					params: {
						"id": '{$id}'
					}
				}, function(data) {
					if (data && !data.code) {
						if (favorite == "1") {
							me.find("i").html("&#xe606;");
							me.find("span").text("收藏");
							me.attr("favorite", 0);
							me.removeClass('current');
						} else {
							me.find("i").html("&#xe607;");
							me.find("span").text("已收藏");
							me.attr("favorite", 1);
							me.addClass('current');
						}
					}
					$.util.pageLoading.hide();
				});
			});
		},
		getCartGoodsNum:function () {
			var me = this;
			var customerId=$.util.getParam("customerId");
			$.req.get("call.json?module=product&customerId="+customerId+"&method=getCarNum",{
				params:{
					"type":"buy",
					"sid":"-1"
				}
			},function(data){
				if (!data.code) {
					$("#carNum").text(data.total || 0).data("num", data.total);
					detail.cartList = data.list;
					if (data && data.total > 0) {
						$("#car").addClass("to-car");
					} else {
						$("#car").removeClass("to-car");
					}
				}
			});
		},
		getShareUrl:function(){
			var p=$.util.getParamAsObject();
			var shareUrl="";
			var me=this;
			var mallQId = "{$quanInfo.qId}";
			var mallUId = "{$quanInfo.uId}";
			if(p.qId||(mallQId&&mallUId)){
				var params={
					"id":"{$id}",
					"fromUserName":"{$userName}",
					"qId":p.qId||mallQId,
					"miUId":p.miUId||mallUId
				}
			}else{
				var params={
					"id":"{$id}",
					"fromUserName":"{$userName}"
				}
			}
			params=encodeURIComponent(JSON.stringify(params));
			shareUrl=baseUrl+'call.html?customerId={$customerId}&module=product&method=getProduct&params='+params;
			return shareUrl;
		},
		goCart:function(vId){
			var p=$.util.getParamAsObject();
			var params=$.extend(p,{
				"sid":"-1",
				"type":"buy",
				"tplid":"4",
				"mid":4,
				"vId":vId,
				"qId":p.qId||"{$quanInfo.qId}",
				"miUId":p.miUId||"{$quanInfo.miUId}"
			});
			params=encodeURIComponent(JSON.stringify(params));
			location.href = 'call.html?customerId={$customerId}&module=product&method=getCart&params=' + params;
		}

	}
	detail.init();
	var shareUrl=detail.getShareUrl();
	wx_share.init({
		"title":"{$title}",
		"desc":'{$recommend}',
		"link":shareUrl,
		"imgUrl": $.trim($("#shareImg").val()),
		"pkg":{
			"appId": '{$pkg.appId}',
			"timestamp": '{$pkg.timestamp}',
			"nonceStr": '{$pkg.nonceStr}',
			"signature": '{$pkg.signature}'
		},
		success:function(config,shareType){
			var p=$.util.getParamAsObject();
			$.req.get("call.json?customerId={$customerId}&module=quan&method=saveShare",{
				params:{
					"qId":p.qId,
					"sId":"{$sId}",
					"guid":detail.guid,
					"fromGuid":p.fromGuid || "",
					"miUId":p.miUId,
					"shareType":shareType,
					"fromPage":"product_detail"
				}
			},function(data){
				if(data && !data.code){
					detail.guid=data.guid;
				}
			});
		}
	});
	var showImg=function(){

		$('.comnt-img').each(function(){
			var imgs=new Array;
			$(this).children().each(function(){
				var _index=$(this).find('img').attr('src').split('@')[0];
				imgs.push(_index);
			})
			$(this).children().unbind('click');
			$(this).children().click(function(){
				var activeImg=$(this).find('img').attr('src').split('@')[0];
				wx_share.showImg(imgs,activeImg);
			})
		});
	}


</script>
</body></html>
